package cn.edu.scau.cmi.luowanghaoyun.client;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;



public class Client {
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver");
		String url = "jdbc:mysql://localhost:3306/jsp";
		String username = "root"; 
		String password = "root"; 
		Connection conn = DriverManager.getConnection(url, username, password); 
		
	String insertSqlStatic ="insert into tb_student(age,sex,name,id) values('21','0','zhangsan','1')";
	Statement ps = conn.prepareStatement(insertSqlStatic);
		
		
		
		
		String insertSqlDynamic = "insert into tb_student(age,sex,name,id) values(?,?,?,?)";
		PreparedStatement dps = conn.prepareStatement(insertSqlDynamic);
		dps.setInt(1,22);
		dps.setInt(2,1);
		dps.setString(3,"lisi");
		dps.setInt(4,2);
		
		
	ps.executeUpdate(insertSqlStatic);
		dps.execute();
		System.out.print("OK");
		
		
			
	}

}
